<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: howl.ui.Window</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-1.12.3.min.js" type="text/javascript"></script>
    <script src="/javascripts/bootstrap.min.js" type="text/javascript"></script>
    
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_api doc_api_ui doc_api_ui_window'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl Documentation (master branch)</a></li><li>Api</li><li>Ui</li><li>howl.ui.Window</li></ol>
      <h1 id="howl.ui.window">howl.ui.Window</h1>    <div class="toc">
      <div class="toc-title">
        <span>howl.ui.Window</span>
      </div>
      <div class="toc-entries">
<div class="toc-group">
<a href="#properties" class="toc-group-header properties">Properties</a>
<li class=""><a href="#command_line">command_line</a></li>
<li class=""><a href="#current_view">current_view</a></li>
<li class=""><a href="#focus_child">focus_child</a></li>
<li class=""><a href="#fullscreen">fullscreen</a></li>
<li class=""><a href="#maximized">maximized</a></li>
<li class=""><a href="#status">status</a></li>
<li class=""><a href="#views">views</a></li>
</div>
<div class="toc-group">
<a href="#methods" class="toc-group-header methods">Methods</a>
<li class=""><a href="#siblings">siblings </a></li>
<li class=""><a href="#to_gobject">to_gobject </a></li>
<li class=""><a href="#add_view">add_view </a></li>
<li class=""><a href="#remember_focus">remember_focus </a></li>
<li class=""><a href="#remove_view">remove_view </a></li>
<li class=""><a href="#get_view">get_view </a></li>
</div>
</div>
</div>
&#x000A;&#x000A;<p>Windows are the primary top-level user interface components in Howl. They can&#x000A;hold an arbitrary number of other user interface components within, called&#x000A;&ldquo;views&rdquo;, which are all ordered in a grid. The most common examples of such a&#x000A;views are of course <a href="editor.html">Editor</a> instances, but it&rsquo;s possible to place various other&#x000A;types of graphical components in a Window, although there are currently no&#x000A;examples of this.</p>&#x000A;&#x000A;<p>A window has, apart from the grid components described above, always two&#x000A;graphical elements associated with it; A <a href="status.html">Status</a> instance used for displaying&#x000A;informational message to the user, and a <a href="command_line.html">CommandLine</a> instance allowing for user&#x000A;input.</p>&#x000A;&#x000A;<p>The currently focused window is accessible as&#x000A;<a href="../application.html#window">Application.window</a>.</p>&#x000A;&#x000A;<p>A Window delegates to the corresponding Gtk Window, which means that you can&#x000A;access GtkWindow properties and methods directly on the Window instance. For&#x000A;example:</p>&#x000A;<pre class="highlight lua"><span class="n">howl</span><span class="p">.</span><span class="n">app</span><span class="p">.</span><span class="n">window</span><span class="p">.</span><span class="n">accept_focus</span> <span class="c1">-- =&gt; true</span>&#x000A;<span class="n">howl</span><span class="p">.</span><span class="n">app</span><span class="p">.</span><span class="n">window</span><span class="p">:</span><span class="n">get_size</span><span class="p">()</span> <span class="c1">-- =&gt; 1920, 1056</span>&#x000A;</pre>&#x000A;<p><em>See also</em>:</p>&#x000A;&#x000A;<ul>&#x000A;<li>The <a href="../../spec/ui/window_spec.html">spec</a> for Window</li>&#x000A;</ul>&#x000A;&#x000A;<h2 id="properties">Properties</h2>&#x000A;&#x000A;<h3 id="command_line">command_line</h3>&#x000A;&#x000A;<p>A <a href="command_line.html">CommandLine</a> instance associated with the window.</p>&#x000A;&#x000A;<h3 id="current_view">current_view</h3>&#x000A;&#x000A;<p>The currently focused view. The return value is a table with same fields as is&#x000A;documented in <a href="#views">views</a>.</p>&#x000A;&#x000A;<h3 id="focus_child">focus_child</h3>&#x000A;&#x000A;<p>The currently focused Gtk view within the window.</p>&#x000A;&#x000A;<h3 id="fullscreen">fullscreen</h3>&#x000A;&#x000A;<p>A boolean indicating whether the window is fullscreen or not. Assign to this to&#x000A;force a particular state.</p>&#x000A;&#x000A;<h3 id="maximized">maximized</h3>&#x000A;&#x000A;<p>A boolean indicating whether the window is maximized or not. Assign to this to&#x000A;force a particular state.</p>&#x000A;&#x000A;<h3 id="status">status</h3>&#x000A;&#x000A;<p>A <a href="status.html">Status</a> instance associated with the window.</p>&#x000A;&#x000A;<h3 id="views">views</h3>&#x000A;&#x000A;<p>A list of view information for the currently existing views in the window grid.&#x000A;Each element is a table with the following fields:</p>&#x000A;&#x000A;<ul>&#x000A;<li><code>x</code>: The horizontal position of the view in the grid (1-based)</li>&#x000A;<li><code>y</code>: The vertical position of the view in the grid (1-based)</li>&#x000A;<li><code>width</code>: The number of horizontal grid squares the view spans</li>&#x000A;<li><code>height</code>: The number of vertical grid squares the view spans</li>&#x000A;<li><code>view</code>: A reference to the Gtk view</li>&#x000A;</ul>&#x000A;&#x000A;<p>The returned list is sorted in left-to-right, top-to-bottom order.</p>&#x000A;&#x000A;<p>Note that the <code>view</code> field, as the documentation says, holds a reference to the&#x000A;&ldquo;Gtk view&rdquo;. This means that you cannot expect this to be, for instance, a&#x000A;reference to an <a href="editor.html">Editor</a>. Should you need to map a particular view to an&#x000A;<a href="editor.html">Editor</a> instance, you could instead iterate through&#x000A;<a href="../application.html#editors">Application.editors</a> and see whether an Editor&rsquo;s&#x000A;<a href="editor.html#to_gobject">to_gobject</a> corresponds to the <code>view</code> field.</p>&#x000A;&#x000A;<h2 id="methods">Methods</h2>&#x000A;&#x000A;<h3 id="siblings">siblings <span class="arg-list">(view, wraparound = false)</span></h3>&#x000A;&#x000A;<p>Returns a a table of siblings for <code>view</code>, which should be a Gtk view. The&#x000A;returned table contains four values accessible through the keys <code>up</code>, <code>down</code>,&#x000A;<code>left</code> and <code>right</code>. Each value is a table with same fields as is documented in&#x000A;<a href="#views">views</a>.</p>&#x000A;&#x000A;<p><code>wraparound</code> controls what is returned if no sibling is found for a particular&#x000A;direction. If it&rsquo;s <code>false</code>, as is the default, <code>nil</code> is returned if no sibling&#x000A;can be found for a particular direction. If it&rsquo;s <code>true</code>, then the search for&#x000A;siblings will wrap around in a left-to-right, top-to-bottom order fashion.</p>&#x000A;&#x000A;<h3 id="to_gobject">to_gobject <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Returns the underlying Gtk window.</p>&#x000A;&#x000A;<h3 id="add_view">add_view <span class="arg-list">(view, placement = &lsquo;right_of&rsquo;, anchor = @focus_child)</span></h3>&#x000A;&#x000A;<p>Adds <code>view</code> to the grid. If <code>view</code> is not a Gtk view, it&rsquo;s automatically cast&#x000A;using the view&rsquo;s <code>to_gobject</code>, if it&rsquo;s present. <code>placement</code> specifies where to&#x000A;place the view in the grid, relative to <code>anchor</code> which should be an existing&#x000A;view in the grid. Valid values for <code>placement</code> are:</p>&#x000A;&#x000A;<ul>&#x000A;<li><code>left_of</code>: Places the view left of <code>anchor</code></li>&#x000A;<li><code>right_of</code>: Places the view right of <code>anchor</code>.</li>&#x000A;<li><code>above</code>: Places the view above <code>anchor</code>.</li>&#x000A;<li><code>below</code>:Places the view below <code>anchor</code>.</li>&#x000A;</ul>&#x000A;&#x000A;<h3 id="remember_focus">remember_focus <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Remember the currently focussed view as the focussed view until the focus&#x000A;switches to another view in the grid. This means even when the focus switches to&#x000A;a view outside the grid, peroperties and methods that use the current view - for&#x000A;example, <a href="#current_view"><code>current_view</code></a> - will continue to use the remembered&#x000A;view.</p>&#x000A;&#x000A;<h3 id="remove_view">remove_view <span class="arg-list">(view = nil)</span></h3>&#x000A;&#x000A;<p>Removes the specified <code>view</code>, or the currently focused view if not specified,&#x000A;from the grid.</p>&#x000A;&#x000A;<h3 id="get_view">get_view <span class="arg-list">(o)</span></h3>&#x000A;&#x000A;<p>Gets the view information for the object <code>o</code>. The return value is a table with&#x000A;same fields as is documented in <a href="#views">views</a>. Returns <code>nil</code> if <code>o</code> is not in&#x000A;the window grid.</p>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2016
            <a class='alert-link' href='https://github.com/howl-editor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
